package com.zyz.K_集合.Map接口五Properties;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * @author: vick
 * @Date: 2025/3/31
 * @Description:
 * @version: 1.0
 */
public class Demo {
    public static void main(String[] args) throws IOException {
        Properties properties = System.getProperties();
        //当前文件的字符编码
        String fileEncoding = properties.getProperty("file.encoding");
        System.out.println(fileEncoding);
        System.out.println("=====");
        Properties properties1 = new Properties();
        properties1.setProperty("userName", "vick");
        properties1.setProperty("password", "123456");
        System.out.println(properties1);

        System.out.println("=====");
        Properties properties2 = new Properties();
        //使用 FileInputStream 打开配置文件
        //使用load方法从文件加载属性
        properties2.load(new FileInputStream("jdbc.properties"));
        String user = properties2.getProperty("user");
        System.out.println(user);
    }
}
